<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        window.onload = function () {
            showLoginUser()
            showChannel()
        }

        function showLoginUser() {
            axios.get("/user/getUserName",null).then(e => {
                var info = e.data;
                $("userImg").src="/html/img/"+info.face;
                $("userName").innerHTML = info.name;
                $("userEmail").innerHTML = info.email;
            })
        }

        function showChannel() {
            axios.get("/channel/findAll",null).then(e => {
                var info = e.data;
                var str = "";
                for (var i=0;i<info.length;i++){
                    str += `<tr>
                        <td><a href="/html/post.html?id=${info[i].id}">${info[i].name}</a></td>
                        <td>${info[i].introduce}</td>
                        <td>${info[i].postNum}</td>
                    </tr>`
                }
                $("bodyData").innerHTML = str;
            })
        }
    </script>
</head>
<body>
    <h2>登录用户</h2>
    <img src="" id="userImg" width="50" height="50">
    用户名：<span id="userName"></span><br>
    电子邮箱：<span id="userEmail"></span>

    <table border="1" cellspacing="0" width="50%">
        <thead>
            <tr>
                <th>频道</th>
                <th>内容</th>
                <th>数量</th>
            </tr>
        </thead>
        <tbody id="bodyData"></tbody>
    </table>
</body>
</html>